<?php
/**
 * Created by PhpStorm.
 * User: GZ-1
 * Date: 2017/6/3
 * Time: 11:48
 */

include_once "../util.php";

$uinfo=$_REQUEST['uinfo'];
if(empty($uinfo)){
    echo json_encode(array(
        "stats"=>0,
        "msg"=>'账号信息不齐全'
    ));
    return;
}

$uinfo=json_decode($uinfo);
$info=objectToArray($uinfo);

// 默认设置 {"showVibrate":true,"showSound":true,"showUserName":true}
$info['setting']=json_encode(array(
    "showVibrate"=>true,
    "showSound"=>true,
    "showUserName"=>true
));
// 绑定账号信息
$add_result=saveUserInfo($info['usid'],$info['uflag'],$info['uname'],$info['upass'],$info['nickName'],$info['phone'],$info['orgName'],$info['jobTitle'],$info['setting'],$info['utype']);
if($add_result){
    // 绑定账号成功
    echo json_encode(array(
        "stats"=>1,
        'userRows'=>getAllUsers($info['usid']),
        'self'=>selectRecordByKey('users','usid',$info['usid'])
    ));
}else{
    // 绑定账号失败
    echo json_encode(array(
        "stats"=>0,
        "msg"=>"绑定账号失败"
    ));
}


